

package com.opgea.crm.domain.entities;

import java.io.Serializable;
import java.util.Date;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

import com.opgea.crm.domain.entities.security.CrmUser;

@Entity
@Table(name="issue")
public class Issue implements Serializable {

	@Id
	@GeneratedValue
	@Column(name="id")
	private Long id;
	
	@JoinColumn(name="project_id", referencedColumnName="id")
	@ManyToOne(fetch=FetchType.EAGER)
	private ProjectDetails project;
	
	@JoinColumn(name="relatedCustomer", referencedColumnName="id")
	@ManyToOne
	private Lead relatedCustomer;
	
	@Column(name="issueName")
	private String issueName;
	
	@Column(name="moduleId") 
	private String moduleId;
	
	@Column(name="issueReason")
	private String issueReason;
	
	@JoinColumn(name="category")
	@ManyToOne
	private SetupsValue category;
	
	@JoinColumn(name="complexity")
	@ManyToOne
	private SetupsValue complexity;
	
	@JoinColumn(name="status")
	@ManyToOne
	private SetupsValue status;
	
	@JoinColumn(name="priority",referencedColumnName="id" )
	@ManyToOne(fetch=FetchType.EAGER)
	private SetupsValue priority;
	
	@JoinColumn(name="resolution")
	@ManyToOne
	private SetupsValue resolution;
	
	@JoinColumn(name="assignedTo", referencedColumnName="id")
	@ManyToOne
	private Employee assignedTo;
	
	@Column(name="targetDate")
	@Temporal(TemporalType.DATE)
	private Date targetDate;
	
	@Column(name="resolvedDate")
	@Temporal(TemporalType.DATE)
	private Date resolvedDate;
	
	@JoinColumn(name="createdBy", referencedColumnName="username")
	@ManyToOne(fetch=FetchType.LAZY)
	private CrmUser createdBy;
	
	@Column(name="createdAt")
	@Temporal(TemporalType.TIMESTAMP)
	private Date createdAt;
	
	@OneToMany(cascade=CascadeType.ALL, mappedBy="issue")
	private List<IssueComment> comments;
	
	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public ProjectDetails getProject() {
		return project;
	}

	public void setProject(ProjectDetails project) {
		this.project = project;
	}

	public Lead getRelatedCustomer() {
		return relatedCustomer;
	}

	public void setRelatedCustomer(Lead relatedCustomer) {
		this.relatedCustomer = relatedCustomer;
	}

	public String getIssueName() {
		return issueName;
	}

	public void setIssueName(String issueName) {
		this.issueName = issueName;
	}

	public String getModuleId() {
		return moduleId;
	}

	public void setModuleId(String moduleId) {
		this.moduleId = moduleId;
	}

	public void setIssueReason(String issueReason) {
		this.issueReason = issueReason;
	}

	public String getIssueReason() {
		return issueReason;
	}

	public SetupsValue getCategory() {
		return category;
	}

	public void setCategory(SetupsValue category) {
		this.category =  category;
	}

	public SetupsValue getComplexity() {
		return complexity;
	}

	public void setComplexity(SetupsValue complexity) {
		this.complexity = complexity;
	}

	public SetupsValue getStatus() {
		return status;
	}

	public void setStatus(SetupsValue status) {
		this.status = status;
	}

	public SetupsValue getPriority() {
		return priority;
	}

	public void setPriority(SetupsValue priority) { 
		this.priority = priority;
	}

	public Employee getAssignedTo() {
		return assignedTo;
	}

	public void setAssignedTo(Employee employee) {
		this.assignedTo = employee;
	}

	public Date getTargetDate() {
		return targetDate;
	}

	public void setTargetDate(Date targetDate) {
		this.targetDate = targetDate;
	}

	public Date getResolvedDate() {
		return resolvedDate;
	}

	public void setResolvedDate(Date resolvedDate) {
		this.resolvedDate = resolvedDate;
	}

	public CrmUser getCreatedBy() {
		return createdBy;
	}

	public void setCreatedBy(CrmUser createdBy) {
		this.createdBy = createdBy;
	}

	public Date getCreatedAt() {
		return createdAt;
	}

	public void setCreatedAt(Date createdAt) {
		this.createdAt = createdAt;
	}


	public void setResolution(SetupsValue resolution) {
		this.resolution = resolution;
	}

	public SetupsValue getResolution() { 
		return resolution;
	}

	public void setComments(List<IssueComment> comments) {
		this.comments = comments;
	}

	public List<IssueComment> getComments() {
		return comments;
	}

}
